package com.triones.ljr.controller.api;

import cn.dev33.satoken.annotation.SaIgnore;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.page.TableDataInfo;
import com.triones.ljr.entity.bo.PolicyParams;
import com.triones.ljr.entity.vo.BannerVO;
import com.triones.ljr.entity.vo.CustomPolicyVO;
import com.triones.ljr.entity.vo.EnterpriseRecommendVO;
import com.triones.ljr.service.BannerService;
import com.triones.ljr.service.EnterpriseRecommendService;
import com.triones.ljr.service.PolicyService;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.NotBlank;
import java.util.List;

/**
 * api - 首页
 *
 * @Author: triones
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/api/home")
public class ApiHomeController extends BaseController {

    private final BannerService bannerService;

    private final EnterpriseRecommendService enterpriseRecommendService;

    private final PolicyService policyService;

    /**
     * 获取广告图列表
     */
    @SaIgnore
    @GetMapping("/banner/list")
    public R<List<BannerVO>> list() {
        return R.ok(bannerService.list());
    }

    /**
     * 获取行业分类列表
     * @return
     */
    @SaIgnore
    @GetMapping("/industryCategory/list")
    public R<List<String>> getIndustryCategoryList() {
        return R.ok(enterpriseRecommendService.getIndustryCategoryList());
    }

    /**
     * 根据行业分类获取推荐企业列表
     * @return
     */
    @SaIgnore
    @GetMapping("/enterpriseRecommend/pageList")
    public TableDataInfo<EnterpriseRecommendVO> getEnterpriseRecommendPageList(String industryCategory, PageQuery pageQuery) {
        return enterpriseRecommendService.getEnterpriseRecommendPageList(industryCategory, pageQuery);
    }

    /**
     * 根据行业查询政策列表
     */
    @GetMapping("/policy/list")
    public R<List<CustomPolicyVO>> policyListByIndustry(@NotBlank(message = "行业不能为空") String industry) {
        return R.ok(policyService.policyListByIndustry(industry));
    }
}
